import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

public class EasyErr {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        Map<String,Integer> map = new LinkedHashMap<>();
        while(s.hasNext()) {
            String str = s.next();
            int n = s.nextInt();
            String[] strs = str.split("\\\\");
            String name = strs[strs.length - 1];
            if(name.length() > 16) {
                name = name.substring(name.length() - 16);
            }
            String key = name +" " + n;
            if(map.containsKey(key)) {
                map.put(key,map.get(key) + 1);
            }else {
                map.put(key,1);
            }
        }
        int index = 0;
        for(String st : map.keySet()) {
            index++;
            if(index > map.size() - 8) {
                System.out.println(st +" " +map.get(st));
            }
        }
    }
}
